package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MatStation;
import com.indusfo.spc.service.MatStationService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/21 10:38
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "/service/matStation")
public class MatStationController {

    @Autowired
    private MatStationService matStationService;

    //查询
    @RequestMapping(value = "/queryMatStation")
    @ResponseBody
    public JSONObject queryMatStation(MatStation matStation) {
        JSONObject json = matStationService.queryMatStation(matStation);
        return json;
    }

    //新增
    @RequestMapping(value = "/insertMatStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertMatStation(MatStation matStation) {
        JSONObject json = matStationService.insertMatStation(matStation);
        return json;
    }

    //修改
    @RequestMapping(value = "/updateMatStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateMatStation(MatStation matStation) {
        JSONObject json = matStationService.updateMatStation(matStation);
        return json;
    }

    //删除
    @RequestMapping(value = "/deleteMatStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteMatStation(@RequestParam("matStationIds") List<Integer> matStationIds, Integer dataState) {
        dataState = 2;
        JSONObject json = matStationService.deleteMatStation(matStationIds, dataState);
        return json;
    }


    //启用/停用
    @RequestMapping(value = "/definedMatStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedMatStation(@RequestParam("matStationIds") List<Integer> matStationIds, Integer dataState) {
        JSONObject json = matStationService.deleteMatStation(matStationIds, dataState);
        return json;
    }
}
